﻿using SketchUpAPI.NET.Objects;
using SketchUpAPI.NET.SketchUp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace SketchUpConsole.Examples
{
    public class SaveModel
    {
        public static void Run()
        {
            string path = @"ExampleFiles\1.skp";

            SketchUpApplication.Initialize();
            SketchUpModel skp = SketchUpModel.Create();
            var entities = skp.Entities;

            GeometryInput geometry = new GeometryInput();

            Point3D[] points = new Point3D[]
            {
                new Point3D(0, 0, 0),
                new Point3D(100.0.ToModel(), 0, 0),
                new Point3D(100.0.ToModel(), 100.0.ToModel(), 0),
            };

            geometry.AddFace(points);

            entities.Add(geometry, true);

            skp.Save(path, SketchUpAPI.NET.Enums.SUModelVersion.SU2020);
            skp.Dispose();

            SketchUpApplication.Terminate();
        }
    }
}
